using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using GameShow.DAL.DTO;

namespace GameShow.DAL
{
    public class ReportDAL : DALBase
    {
        public DataSet TotalMark(String ps_Type)
        {
            DataSet ds = new DataSet("TT");
            SqlParameter[] values = new SqlParameter[] { new SqlParameter("p_Type", ps_Type)};
            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand command = new SqlCommand();
            try
            {
                command.CommandText = "ReportMark";
                command.CommandType = CommandType.StoredProcedure;
                command.Connection = AppConnection;
                command.Parameters.AddRange(values);
                adapter.SelectCommand = command;
                adapter.Fill(ds, "ITC");      
                
            }
            catch (Exception ex)
            {          
            }
            finally
            {
                AppConnection.Close();
            }
            return ds;
        }
        public DataSet Teams()
        {
            DataSet ds = new DataSet("TT");
            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand command = new SqlCommand();
            try
            {
                command.CommandText = "SELECT TeamId, TeamName FROM tblTeams ORDER BY TeamName";
                command.CommandType = CommandType.Text;
                command.Connection = AppConnection;
                  adapter.SelectCommand = command;
                adapter.Fill(ds, "ITC");

            }
            catch (Exception ex)
            {
            }
            finally
            {
                AppConnection.Close();
            }
            return ds;
        }
        public DataSet DetailMark(int pn_TeamId)
        {
            DataSet ds = new DataSet("TT");
            SqlParameter[] values = new SqlParameter[] { new SqlParameter("p_TeamId", pn_TeamId) };
            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand command = new SqlCommand();
            try
            {
                command.CommandText = "DetailReport";
                command.CommandType = CommandType.StoredProcedure;
                command.Connection = AppConnection;
                command.Parameters.AddRange(values);
                adapter.SelectCommand = command;
                adapter.Fill(ds, "ITC");

            }
            catch (Exception ex)
            {
            }
            finally
            {
                AppConnection.Close();
            }
            return ds;
        }
    }
}
